package pers.qianyu.month_202012.date_20201219.bit_operation;

/**
 * 461. 汉明距离
 * https://leetcode-cn.com/problems/hamming-distance/
 *
 * @author mizzle rain
 * @date 2020-12-19 21:18
 */
public class HammingDistance {
    public int hammingDistance(int x, int y) {
        int a = x ^ y;
        int res = 0;
        while (a != 0) {
            res++;
            a = a & (a - 1);
        }
        return res;
    }
}
